<?php
class CommonAction extends Action
{
	public $Core;
	
	public $isLogin;
	
	public $needNotLogin = array('index', 'public');
	
	public function _initialize(){
		!CORE_LOADED && import('Core', CORE_PATH);
		$this->Core = &Core::instance();
		$this->_init_user_form_mysql();
		$this->isLogin = $this->Core->User->u_id ? true : false ;
		$this->assign( 'user', $this->Core->User ) ;
		if(!in_array(strtolower(MODULE_NAME), $this->needNotLogin) && !$this->isLogin){
			$this->error('请先登录'); # TODO 根据提示跳转登录窗口
		}
	}

	public function _init_user_form_mysql(){
		if(!$this->Core->User->u_id){
			return;
		}else{
			$this->autoPayForAuction();
			$info = getInfoById('User', $this->Core->User->u_id);
			$this->Core->User->u_mobile = $info['u_mobile'];
			$this->Core->User->u_email =  $info['u_email'];
			$this->Core->User->u_liantong =  $info['u_liantong'];
			$this->Core->User->u_address =  $info['u_address'];
			$this->Core->User->u_lock_auid =  $info['u_lock_auid'];
			$this->Core->User->u_run_carddays =  $info['u_run_carddays'];
			$this->Core->User->u_carddays =  $info['u_carddays'];
			$this->Core->User->u_golds =  $info['u_golds'];
		}
	}
	
	# 自动扣去拍卖商品的价格
	private function autoPayForAuction(){
		import('@.Util.PayForAuction');
		$auto = new PayForAuction($this->Core->User);
		$auto->pay();
	}
	
	
}
?>